package com.ant.temple;

import java.util.ArrayList;
import java.util.List;

import com.ant.temple.activities.Test01;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;


public class MainActivity extends ListActivity {
	private List<String> title=new ArrayList<String>();
	private List<Class> list=new ArrayList<Class>();
	private Intent in=new Intent();
	private ListView lv;
	

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(?R.layout.activity_main);
        
        init();
        data();
        listener();
    }

    private void init() {
    lv = this.getListView();		
	}

	private void data() {
		title.add("defind my view");
		list.add(Test01.class);
		
		
		ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1);
		adapter.addAll(title);
		lv.setAdapter(adapter);
	}

	private void listener() {
		lv.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				in.setClass(MainActivity.this, list.get(position));
				MainActivity.this.startActivity(in);
			}
		});
	}

	@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
